/*
 * @Author: TT-hzy 
 * @Date: 2024-06-25 17:05:38
 * @LastEditors: TT-hzy 
 * @LastEditTime: 2024-06-25 17:15:38
 * @Description: 
 */

import { Service } from "egg";



export class TuChongInfoService extends Service {

    public async list(postId?: string, page: number = 1, type: string = "loadmore"): Promise<any> {
        var data = {};
        if (postId != null) {
            data = {
                post_id: postId,
                page,
                type,
            };
        }
        this.ctx.logger.info(data);
        try {
            const result = await this.request({
                data,
            });
            return result;
        } catch (error) {
            this.ctx.logger.error(error);
            return [];
        }

    }

    async request(opts?: any) {
        const {
            ctx,
        } = this;
        const options = {
            dataType: 'json',
            timeout: '30s',
            ...opts,
        };

        const result = await ctx.curl(this.config.news.serverUrl, options,);
        return result.data;
    }
}


export default TuChongInfoService;